﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using System.Reflection;
using HasuSLLib;

namespace HasuSLUI.Utility
{
    public class OtherExtra
    {

        /// <summary>
        /// enum class not woking in Sl
        /// </summary>
        /// <param name="enumeration"></param>
        /// <returns></returns>
        public static string[] GetNames(Type enumeration)
        {
            List<string> names = new List<string>();
            FieldInfo[] infoCollection = enumeration.GetFields(BindingFlags.Public | BindingFlags.Static);
            foreach (FieldInfo fi in infoCollection)
            {
                names.Add(fi.Name);
            }
            return names.ToArray(); 
        }

        public static Dictionary<string,object>  GetEnumCollection(Type enumeration)
        {
            Dictionary<string, object> namesList = new Dictionary<string,object>();
            FieldInfo[] infoCollection = enumeration.GetFields(BindingFlags.Public | BindingFlags.Static);
            foreach (FieldInfo fi in infoCollection)
            {
                namesList.Add(fi.Name , Enum.Parse(enumeration,fi.Name,true));
            }
            return namesList;
        }

    }

    public  static class UIExtensions
    {
        public static void UpdateLookup(this ILookup lookup, bool forceToUpdate)
        {
            if (lookup != null && (forceToUpdate || lookup.GetValidList().Count==0 ))
            {
                //lookup.GetType().Attributes
            }
        } 
    }
}
